<template>
  <div>
    <div style="z-index:3;margin-bottom:10px;">
        <el-breadcrumb separator-class="el-icon-arrow-right title">
            <el-breadcrumb-item :to="{ path: '/HomeAdmin' }" style="font-size:20px;">首页</el-breadcrumb-item>
            <el-breadcrumb-item style="font-size:20px;">平台盲盒</el-breadcrumb-item>
            <el-breadcrumb-item style="font-size:20px;">销售情况</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div>
      <el-input v-model="key" placeholder="请输入搜索的盲盒名" style="width: 20%; margin-bottom:5px; margin-right:5px;"
      clearable></el-input>
      <el-button type="primary" plain @click="getBlindBoxInfoList(1,10,key)">查询</el-button>
      <!-- <el-button type="primary" plain @click="exportBlindBoxSaleInfo(key)">导出</el-button> -->
      <el-table
        :data="blindBoxInfoList"
        style="width: 100%"
        height="700"
        >
        <el-table-column
          label="盲盒图片"
        >
        <template slot-scope="scope">
            <el-popover placement="top-start" title="" trigger="hover">
                <el-image :src="scope.row.blindBoxImage != null ? require('D:/毕设/前端/blind_box/src/assets/'+scope.row.blindBoxImage):''" alt="暂无图片" style="width: 200px;height: 200px"></el-image>
                <el-image slot="reference" :src="scope.row.blindBoxImage != null ? require('D:/毕设/前端/blind_box/src/assets/'+scope.row.blindBoxImage):''" style="width: 100px;height: 100px"></el-image>
            </el-popover>
        </template>
        </el-table-column>
        <el-table-column
          prop="blindBoxName"
          label="盲盒名"
        >
        </el-table-column>
        <el-table-column
        label="盲盒状态"
        >
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.blindBoxStatus }}</el-tag>
          </div>
        </template>
        </el-table-column>
        <el-table-column
          prop="blindBoxPrice"
          label="盲盒售价"
        >
        </el-table-column>
        <el-table-column
          prop="saleQuantity"
          label="近30天盲盒销售总数量"
        >
        </el-table-column>
        <el-table-column
          prop="saleAmount"
          label="近30天销售总金额"
        >
        </el-table-column>
        <el-table-column
          prop="saleTotalCost"
          label="近30天销售总成本"
        >
        </el-table-column>
        <el-table-column
          prop="saleTotalProfit"
          label="近30天销售总利润"
        >
        </el-table-column>
        <!-- <el-table-column
          fixed="right"
          label="操作"
        > -->
        <!-- <template slot-scope="userInfoList"> -->
          <!-- <el-button @click="getUserDetails(userInfoList.row)" type="text" size="small">查看</el-button> -->
          <!-- <el-button type="text" size="small">编辑</el-button> -->
        <!-- </template> -->
        <!-- </el-table-column> -->
      </el-table>
    </div>
    <!-- 用户详细信息 -->
    <!-- <div>
      <el-dialog title="我的信息" :visible.sync="dialogUserInfo">
        <el-form :model="userInfo" :rules="userInfoRules">
          <el-form-item label="用户名" prop="username" style="font-weight: bolder;">
            <el-input v-model="userInfo.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password" style="font-weight: bolder;"> 
            <el-input v-model="userInfo.password" disabled></el-input>
          </el-form-item>
          <el-form-item label="性别" style="font-weight: bolder;">
            <el-radio-group v-model="userInfo.gender" disabled>
              <el-radio label="男" style="font-weight: bolder;"></el-radio>
              <el-radio label="女" style="font-weight: bolder;"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="手机号码" prop="phoneNumber" style="font-weight: bolder;">
            <el-input v-model="userInfo.phoneNumber" disabled></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="reload()">取消</el-button>
        </div>
      </el-dialog>
    </div> -->
    <div>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="10"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total">
    </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  inject: ['reload'],
  data(){
    return{
      dialogUserInfo: false,
      key: '',
      currentPage: 1,
      blindBoxInfoList: [{
        blindBoxName: null,
        status: null,
        blindBoxImage: null,
        blindBoxPrice: null,
        saleQuantity: null,
        saleAmount: null,
        saleTotalCost: null,
        saleTotalProfit: null,
        blindBoxStatus: null
      }],
      pageInfo: {
        endRow: null,
        hasNextPage: false,
        hasPreviousPage: false,
        isFirstPage: true,
        isLastPage: true,
        list: [],
        navigateFirstPage: null,
        navigateLastPage: null,
        navigatePages: null,
        navigatepageNums: [],
        nextPage: null,
        pageNum: null,
        pageSize: null,
        pages: null,
        prePage: null,
        size: null,
        startRow: null,
        total: null,
      },
    }
  },
  // beforeCreate(){
  //   var token = localStorage.getItem("loginToken")
  //   pageNum = 1
  //   pageSize = 10
  //   this.$axios.get('/admin/getUserInfoList',{params:{pageNum:pageNum,pageSize:pageSize}})
  //   .then(res => {
  //     if(res.data.data != null){
  //       this.pageInfo = res.data.data
  //       this.userInfoList = res.data.data.list
  //     }
  //   })
  //   .catch(err => {
  //   })
  // },
  methods: {
    getBlindBoxInfoList(pageNum,pageSize,key){
      console.log(pageNum,pageSize,key)
      const token = localStorage.getItem("loginToken")
      this.$axios({url:'/merchant/querySalesSituation', methods: 'GET',params:{pageNum:pageNum,pageSize:pageSize,key:key},headers:{"token":token}})
      .then(res => {
        // console.log(res.data.data.list)
        if(res.data.data != null){
          this.pageInfo = res.data.data
          this.blindBoxInfoList = res.data.data.list
          console.log(this.blindBoxInfoList)
        }
        if(res.data.code == 300){
          this.$message({
              showClose: true,
              message: res.data.msg,
              type: "warning"
          })
        }
      })
      .catch(err => {
      })
    },
    handleCurrentChange(pageNum){
      console.log('当前页：'+pageNum)
      this.getBlindBoxInfoList(pageNum,10,this.key)
    },
    handleSizeChange(pageSize){
      console.log('每页'+pageSize+'条')
      this.getBlindBoxInfoList(1,pageSize,this.key)
    },
  }
}
</script>

<style>

</style>
